﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using AutumnEngine.Modules;
using System.Diagnostics;
using AutumnEngine;

namespace AutumnEngine
{
    /// <summary>
    /// A label representing chosen text.
    /// </summary>
    public class LabelNode : Node
    {
        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        /// <value>The text.</value>
        public string Text
        {
            get;
            set;
        }

        SpriteFont _sFont;
        string _font = "";
        /// <summary>
        /// Gets or sets the font.
        /// </summary>
        /// <value>The font.</value>
        public string Font
        {
            get { return _font; }
            set 
            { 
                _font = value;
                _sFont = Engine.Modules.FontManager.GetFont(_font);
            }
        }

        /// <summary>
        /// Gets or sets the color.
        /// </summary>
        /// <value>The color.</value>
        public Color Color
        {
            get;
            set;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="LabelNode"/> class.
        /// </summary>
        /// <param name="spriteFont">The sprite font's name in the FontManager.</param>
        public LabelNode(string spriteFont)
        {
            Font = spriteFont;
            Color = Color.Black;
            Origin = Vector2.Zero;
            Scale = 1f;
        }

        /// <summary>
        /// Gets or sets the rotation.
        /// </summary>
        /// <value>The rotation.</value>
        public virtual float Rotation
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the origin.
        /// </summary>
        /// <value>The origin.</value>
        public Vector2 Origin
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the scale.
        /// </summary>
        /// <value>The scale.</value>
        public float Scale
        {
            get;
            set;
        }

        /// <summary>
        /// Draws this instance.
        /// </summary>
        public override void Draw()
        {
            Engine.SpriteBatch.DrawString(_sFont, Text, this.Position, this.Color, Rotation, Origin, this.Scale, SpriteEffects.None, 0f);
            base.Draw();
        }
    }
}
